# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=py3-transmission-rpc
pkgver=7.0.3
pkgrel=1
pkgdesc="python module implementing the json-rpc client protocol for the BitTorrent client Transmission."
url="https://transmission-rpc.readthedocs.io/"
arch="noarch"
license="MIT"
depends="python3 py3-requests py3-typing-extensions"
makedepends="py3-poetry-core py3-gpep517"
checkdepends="py3-pytest py3-tz py3-yarl transmission-daemon"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/trim21/transmission-rpc/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/transmission-rpc-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	local pidfile="$srcdir/transmission-daemon.pid"
	transmission-daemon -r 127.0.0.1 -w "$srcdir" -x "$pidfile"
	trap 'kill $(cat "$pidfile")' EXIT

	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest

	kill "$(cat "$pidfile")" || true
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
e2ae967ba85e7cef8e57a8371245d2c1a8fb4da4fe2ac883aeff231cb35fc1565f4d197de59b4e744bd95938ba689dbeb9348f6e9390825d0a0f36614a2e6f09  py3-transmission-rpc-7.0.3.tar.gz
"
